package com.iversonx.scene_1.v1;

import com.iversonx.scene_1.entity.Matter;
import com.iversonx.scene_1.entity.ceiling.LevelOneCeiling;
import com.iversonx.scene_1.entity.ceiling.LevelTwoCeiling;
import com.iversonx.scene_1.entity.coat.DuluxCoat;
import com.iversonx.scene_1.entity.coat.LiBangCoat;
import com.iversonx.scene_1.entity.floor.ShengXiangFloor;
import com.iversonx.scene_1.entity.tile.DongPengTile;
import com.iversonx.scene_1.entity.tile.MarcoPoloTile;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 *
 **/
public class DecorationPackageController {
    public String getMatterList(BigDecimal area, Integer level) {
        // 装修清单
        List<Matter> list = new ArrayList<Matter>();
        // 装修价格
        BigDecimal price = BigDecimal.ZERO;
        
        
        if (1 == level) {
            // 豪华欧式
            // 吊顶，二级顶
            LevelTwoCeiling levelTwoCeiling = new LevelTwoCeiling();
            // 涂料，多乐士
            DuluxCoat duluxCoat = new DuluxCoat();
            // 地板，圣象
            ShengXiangFloor shengXiangFloor = new ShengXiangFloor();
            
            list.add(levelTwoCeiling);
            list.add(duluxCoat);
            list.add(shengXiangFloor);
            
            price = price.add(area.multiply(new BigDecimal("0.2")).multiply(levelTwoCeiling.price()));
            price = price.add(area.multiply(new BigDecimal("1.4")).multiply(duluxCoat.price()));
            price = price.add(area.multiply(shengXiangFloor.price()));
            
        } else if (2 == level) {
            // 轻奢田园
    
            // 吊顶，二级顶
            LevelTwoCeiling levelTwoCeiling = new LevelTwoCeiling();
    
            // 涂料，立邦
            LiBangCoat liBangCoat = new LiBangCoat();
    
            // 地砖，马可波罗
            MarcoPoloTile marcoPoloTile = new MarcoPoloTile();
            
            list.add(levelTwoCeiling);
            list.add(liBangCoat);
            list.add(marcoPoloTile);
            
            price = price.add(area.multiply(new BigDecimal("0.2")).multiply(levelTwoCeiling.price()));
            price = price.add(area.multiply(new BigDecimal("1.4")).multiply(liBangCoat.price()));
            price = price.add(area.multiply(marcoPoloTile.price()));
            
        } else if (3 == level) {
            // 现代简约
    
            // 吊顶，二级顶
            LevelOneCeiling levelOneCeiling = new LevelOneCeiling();
    
            // 涂料，立邦
            LiBangCoat liBangCoat = new LiBangCoat();
    
            // 地砖，东鹏
            DongPengTile dongPengTile = new DongPengTile();
            
            list.add(levelOneCeiling);
            list.add(liBangCoat);
            list.add(dongPengTile);
            
            price = price.add(area.multiply(new BigDecimal("0.2")).multiply(levelOneCeiling.price()));
            price = price.add(area.multiply(new BigDecimal("1.4")).multiply(liBangCoat.price()));
            price = price.add(area.multiply(dongPengTile.price()));
        }
        
        StringBuilder detail = new StringBuilder("\r\n-------------------------------------------------------\r\n" +
                "装修清单" + "\r\n" +
                "套餐等级：" + level + "\r\n" +
                "套餐价格：" + price.setScale(2, BigDecimal.ROUND_HALF_UP) + " 元\r\n" +
                "房屋面积：" + area.doubleValue() + " 平米\r\n" +
                "材料清单：\r\n");
        
        for (Matter matter: list) {
            detail.append(matter.scene()).append("：").append(matter.brand()).append("、").append(matter.model()).append("、平米价格：").append(matter.price()).append(" 元。\n");
        }
        
        return detail.toString();
        
    }
}
